#include "chooselevelscene.h"
#include<QmenuBar>
#include<QPainter>
#include"mypushbutton.h"
#include<QDebug>
ChooseLevelScene::ChooseLevelScene(QWidget *parent) : QMainWindow(parent)
{
    //配置选择关卡的场景
    this->setFixedSize(320,588);
    //设置图标
    this->setWindowIcon(QPixmap(":/res/Coin0001.png"));
    //设置标题
    this->setWindowTitle("选择关卡场景");

    //创建菜单栏
    QMenuBar * bar=menuBar();
    setMenuBar(bar);
    //创建开始菜单
    QMenu * startMenu=bar->addMenu("开始");
    //创建退出的菜单项
    QAction * quitAction=startMenu->addAction("退出");
    //点击退出 实现退出游戏
    connect(quitAction,&QAction::triggered,[=](){
        this->close();
    });
    //返回按钮
    MyPushButton * backBtn=new MyPushButton(":/res/BackButton.png",":/res/BackButtonSele");
    backBtn->setParent(this);
    backBtn->move(this->width()-backBtn->width(),this->height()-backBtn->height());
    //点击返回
    connect(backBtn,&MyPushButton::clicked,[=](){
       qDebug()<<"点击了返回按钮";
    });


}
 void ChooseLevelScene::paintEvent(QPaintEvent *)
 {
   QPainter painter(this);
   QPixmap pix;
  //pix.load(":/res/OtherSceneBg.png");
   pix.load(":/res/secondbeijing.jpg");
   painter.drawPixmap(0,0,this->width(),this->height(),pix);

   //加载标题
   pix.load(":/res/Title.png");
   painter.drawPixmap((this->width()-pix.width())*0.5,30,pix.width(),pix.height(),pix);




 }
